--- Reverse the standard input
module examples.ReverseStdin where

main _ = loop [] >>= mapM_ stdout.write

loop :: [Int] -> IO [Int] 
loop acc = do
    i <- stdin.read
    if i < 0 then return acc    -- end of file
    else loop (i:acc)
